package com.example.viewpagedemo;

import java.util.ArrayList;
import java.util.List;

import adapter.ViewPagerAdapter;
import android.os.Bundle;
import android.app.Activity;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;

public class MainActivity extends Activity {
	
	private ViewPager mViewPage;
	private List<View> views;
	private int [] imageId = {R.drawable.intro_page_1,R.drawable.intro_page_2,R.drawable.intro_page_3,R.drawable.intro_page_4};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mViewPage = (ViewPager) findViewById(R.id.myViewPager);
        initViewPage();
    }

	private void initViewPage() {
//		DisplayImageOptions options = new DisplayImageOptions.Builder()
//		.showImageForEmptyUri(R.drawable.default_material_image)
//		.showImageOnFail(R.drawable.default_material_image)
//		.resetViewBeforeLoading(true).cacheOnDisc(true)
//		.imageScaleType(ImageScaleType.EXACTLY)
//		.bitmapConfig(Bitmap.Config.RGB_565)
//		.displayer(new FadeInBitmapDisplayer(300)).build();
		
		views = new ArrayList<View>();//生产ViewPage所需的ImageView的List
		for (int i : imageId) {
			ZoomImageView imageView = new ZoomImageView(MainActivity.this);
			imageView.setImageResource(i);
			views.add(imageView);
		}
		ViewPagerAdapter vpAdapter = new ViewPagerAdapter(views);
		mViewPage.setAdapter(vpAdapter);
		mViewPage.setOnPageChangeListener(new OnPageChangeListener() {
			
			@Override
			public void onPageSelected(int arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onPageScrollStateChanged(int arg0) {
				// TODO Auto-generated method stub
				
			}
		});
	}

    
}
